/**
 * 话题搜索和导航签样式
 *
 * @author sk
 * @since 2018-05-28
 */
$(function () {

    $('body')
        .on('click', '#classSearchBtn', function () { // 搜索按钮
            var search = $('#search').val().trim();
            searchTopic(search);
        })
        .on('keydown', '#search', function (e) { // 回车搜索
            e = e || window.event;
            if (e.keyCode == 13) {
                var search = $('#search').val().trim();
                searchTopic(search);
                return false;
            }
        });

    function searchTopic(search) {
        window.location = baseloaction + '/web/classes/search/searchTopic?search=' + search;
    }

    classesNavigator();

    function classesNavigator() {
        var href = location.href;
        $('li[data-navigator] a').each(function () {
            if (href.indexOf(this.href) != -1) {
                $(this).parent().addClass('active').siblings().removeClass('active');
            }
        })
    }
});